<template>
  <div class="bill">
	<header-bar :text="title" :left="left"></header-bar>
<div class="billallList"
v-if="list.length > 0"
  v-infinite-scroll="loadMore"
  :infinite-scroll-distance="pageSize">
<div class="bill-list" v-for="(item, key) in list" :key="key" style="height:73px">
  <div class="bill-head">
		<div class="bill-head-r">
            <div class="bill-head-r-p" style="margin-bottom:16px;">
				<span class="days">{{item.name}} ({{item.type == 1 ? '固收' : '浮收'}})</span>
			</div>
			<div class="bill-head-r-p">
				<div style="color:#353535">锁仓：<span style="font-weight: 600;">{{ (item.totalAmountView - item.surplusAmountView).toFixed(2)}}{{item.coinType}}</span></div>
				<div>
					<span style="color:#EC5757;font-weight: 600;">{{item.profit}}%</span>
				</div>
			</div>
			<div class="bill-head-r-p" style="font-size:13px;">
				<span style="color:#888">{{item.dayType}}天定期 &nbsp; {{item.endTime | getTime}}</span>
				<span>
					<div class="bill-status" style="color:#353535;">年化收益</div>
				</span>
			</div>
		</div>
    
  </div>
</div>
</div>
<div class="noData" v-else>暂无数据</div> 
  </div>
</template>
<script>
import {
  Header,
  CellSwipe,
  InfiniteScroll,
  Toast,
  Indicator,
  MessageBox
} from "mint-ui";
import headerBar from "./main/header";
import moment from "moment";
import { transactList } from "../api/api.js";
import util from '../assets/js/util.js'
console.log(util)
export default {
  name: "Bill",
  data() {
    return {
      msg: "",
      title: "往期产品收益",
      left: {
        status: true
      },
      list: [
        // {
        //   payStatus: 2,
        //   type: 2,
		//   payAmount: 123,
		//   totalAmountView:10000,
		//   surplusAmountView:10000,
		//   endTime:"2018-05-24T09:46:01.000+0000"
		// },
		// {
        //   payStatus: 2,
        //   type: 2,
		//   payAmount: 123,
		//   endTime:"2018-05-24T09:46:01.000+0000"
        // }
      ],
      pageNum: 1,
	  pageSize: 5,
	  params:{}
    };
  },
  components: {
    headerBar
  },
  filters:{
	  getTime(time){
		  return util.time.getNowTime1(time)
	  }
  },
  methods: {
    getTransactList(p) {
      let para = {
        pageNum: p,
        pageSize: this.pageSize,
        
	  };
	  para = Object.assign(para,this.params);
      this.$ajaxGet("hosityList", para).then(res => {
		Indicator.close();
		 if (res.code !== 200) {
            Toast({
              message: res.msg,
              position: "bottom",
              duration: 5000
            });
          }else{
			  this.list = res.data;
		  }
        
      });
    //   transactList(para)
    //     .then(res => {
    //       Indicator.close();
    //       if (res.code !== 200) {
    //         Toast({
    //           message: res.msg,
    //           position: "bottom",
    //           duration: 5000
    //         });
    //       } else {
    //         for (var i = 0; i < res.data.length; i++) {
    //           res.data[i].payTime = moment(
    //             new Date(res.data[i].payTime)
    //           ).format("MM-DD HH:mm");
    //         }
    //         if (this.list == "") {
    //           this.list = res.data;
    //         } else {
    //           this.list = this.list.concat(res.data);
    //         }
    //       }
    //     })
    //     .catch(err => {
    //       Toast({
    //         message: "请求超时",
    //         position: "bottom",
    //         duration: 5000
    //       });
    //     });
    },
    loadMore() {
      //hosityList
      Indicator.open("加载中...");
      this.pageNum = this.pageNum + 1;
      this.getTransactList(this.pageNum);
    }
  },
  mounted() {
	this.params = this.$route.query;
    // this.getTransactList(1);
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
@import url("../../static/css/oldincome.css");
</style>
